;
; Copyright (c) Microsoft Corporation.  All rights reserved.
;
;
; Use of this source code is subject to the terms of the Microsoft end-user
; license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
; If you did not accept the terms of the EULA, you are not authorized to use
; this source code. For a copy of the EULA, please see the LICENSE.RTF on your
; install media.
;


		INCLUDE kxarm.h
		INCLUDE armmacros.s
		INCLUDE s3c2443.inc

;-------------------------------------------------------------------------------

MemoryMap       EQU     0x2a4
BANK_SIZE       EQU     0x00100000      ; 1MB per bank in MemoryMap array
BANK_SHIFT      EQU     20


;   Define RAM space for the Page Tables:
;
PHYBASE	 EQU     0x30000000      ; physical start
PTs	     EQU     0x30010000      ; 1st level page table address (PHYBASE + 0x10000)
					; save room for interrupt vectors.

;-------------------------------------------------------------------------------

	TEXTAREA

	IMPORT  BootloaderMain

; Set up the MMU and Dcache for bootloader.
;
; This routine will initialize the first-level page table based up the contents
; of the MemoryMap array and enable the MMU and caches.
;
; Copy the image to RAM if it's not already running there.
;
; Include Files 


;---------------------------------------------------------------------------
;	4 LED light function
;	The LEDs are located below AMD Flash ROM

	MACRO

         LED_ON   $data
         LDR      r10, =0x560000d4        
         LDR      r11, =$data
         MOV     r11, r11, lsl #4
         MOV     r11, r11, lsl #5
         STR      r11, [r10]

	MEND

;---------------------------------------------------------------------------


;-------------------------------------------------------------------------------
;   Function: Startup
;
;   Main entry point for CPU initialization.
;

	STARTUPTEXT
	LEAF_ENTRY      StartUp
	; Shouldn't get here.
	b       %F20

	INCLUDE oemaddrtab_cfg.inc
 

	; Compute physical address of the OEMAddressTable.
20	add     r11, pc, #g_oalAddressTable - (. + 8)

	;led show
	;LED_ON 1
	;bl _LedOn
	
	mov     sp, #0x30000000	; have to be modefied. refer config.bib	
	add     sp, sp, #0x30000	; arbitrary initial super-page stack pointer
	add     sp, sp, #0x8000	; arbitrary initial super-page stack pointer	
	b       BootloaderMain

	ENTRY_END



;-------------------------------------------------------------------------------
;
;  Function:  _LedOn()
;
	LEAF_ENTRY _LedOn
        	LDR      r10, =0x56000000      
	MOV      r11, #1
	MOV     r11, r11, lsl #4
	MOV     r11, r11, lsl #5
	STR      r11, [r10,#0xD4]
	bx          lr
	END